package cn.sylinx.horm.spring.boot;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;

import cn.sylinx.horm.config.DataSourceConfig;
import cn.sylinx.horm.config.OrmConfig;

@ConfigurationProperties(prefix = "horm.config")
public class HORMBootConfig extends OrmConfig implements InitializingBean {

    private boolean transactionNative;

    // 数据源相关
    private DataSourceConfig datasource;

    public DataSourceConfig getDatasource() {
        return datasource;
    }

    public void setDatasource(DataSourceConfig datasource) {
        this.datasource = datasource;
    }

    public boolean isTransactionNative() {
        return transactionNative;
    }

    public void setTransactionNative(boolean transactionNative) {
        this.transactionNative = transactionNative;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        if (datasource == null) {
            datasource = new DataSourceConfig();
        }
    }

}
